package com.blank.task11;

import java.util.Objects;

public class Student {
    //私有化成员变量
    private int stuNumber;  //学号
    private String name;    //姓名
    private int age;        //年龄

    public Student() {
    }

    public Student(int stuNumber, String name, int age) {
        setName(name);
        setAge(age);
        setStuNumber(stuNumber);
    }

    public int getStuNumber() {
        return stuNumber;
    }

    public void setStuNumber(int stuNumber) {
        this.stuNumber = stuNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    //以学号作为评判基准
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return stuNumber == student.stuNumber;
    }

    @Override
    public int hashCode() {
        return Objects.hash(stuNumber);
    }

    @Override
    public String toString() {
        return "Student{" +
                "学号=" + stuNumber +
                ", 姓名='" + name + '\'' +
                ", 年龄=" + age +
                '}';
    }
}
